package com.lc.ibps.platform.rest.org;

import java.util.List;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.lc.ibps.api.auth.service.ISubSysQueryService;
import com.lc.ibps.base.core.util.AppUtil;
import com.lc.ibps.base.core.util.JacksonUtil;
import com.lc.ibps.cloud.entity.APIResult;
import com.lc.ibps.org.auth.persistence.entity.SubSystemPo;
import com.lc.ibps.web.controller.BaseApiController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/** 
 * 子系统服务 控制器，第三方系统调用。
 *
 * <pre> 
 * 构建组：ibps-platform-webapi
 * 作者：simon cai
 * 邮箱：48847557@qq.com
 * 日期：2017年7月20日-下午5:00:07
 * 版权：广州流辰信息技术有限公司版权所有
 * </pre>
 */

@RequestMapping(value="/api/webapi/subSysService")
@Api(value = "/subSysService",tags="用户管理-子系统服务")
@RestController
public class SubSysController extends BaseApiController{

	
	private ISubSysQueryService subSysService;
	
	public SubSysController(){
		subSysService = AppUtil.getBean(ISubSysQueryService.class);
	}

	@ApiOperation(value = "根据ID获取角色", notes = "根据ID获取角色")
	@RequestMapping(value="/getAllSubSys",method=RequestMethod.GET)
	public APIResult<List<SubSystemPo>> getAllSubSys() {
		
		APIResult<List<SubSystemPo>> result = new APIResult<>();
		String listData = null;
		List<SubSystemPo> list = null;
		try {
			listData = subSysService.findAll();
			if(JacksonUtil.isJsonArray(listData)){
				list = JacksonUtil.getDTOList(listData, SubSystemPo.class);
			}
			result.setData(list);
			result.setMessage("成功获取数据！");
		} catch (Exception e) {
			result = getExceptionResult(result, ERROR, "获取数据失败！", e);
		}
		
		return result;
	}
	
}
